/**
 * 
 */
package org.jinion.database;

/**
 * This Enum stores all Supported Database types.
 * @author zhlmmc
 *
 */
public enum DatabaseType {
	MYSQL(1),
	MSSQL(2),
	ORACLE(3),
	UNSUPPORT(Integer.MIN_VALUE);
	
	private int code;
	
	private DatabaseType(int code){
		this.code = code;
	}
	
	public String toString(){
		switch (code) {
		case 1:
			return "MYSQL";
		case 2:
			return "SQL Server";
		case 3:
			return "ORACLE";
		default:
			return "Unsupported database";
		}
	}
	
	public static DatabaseType getDBType(String connectionURL){
		//TODO: currently, only support mysql.
		if (connectionURL.startsWith("jdbc:mysql")) {
			return MYSQL;
		}
		return UNSUPPORT;
	}
}
